package models

import (
	"strings"
)

type RelationCodeTag struct {
	RelationId int `json:"relationid,omitempty"`
	CodeId     int `json:"cid,omitempty"`
	TagId      int `json:"tid,omitempty"`
}

//插入关联
func (db *DB) InsertRelation(codeid int64, tageids string) {

	tagelist := strings.Split(tageids, ",")

	stmt,err := db.Prepare("INSERT INTO `snippets_box`.`relation_code_tag`(`code_id`, `tag_id`) VALUES (?, ?)")
	checkErr(err)

	for t := range tagelist{
		stmt.Exec(codeid,t)
	}
}
